import { createRouter, createWebHashHistory } from 'vue-router';
// import routes from 'virtual:generated-pages';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';

const routes = [
  {
    path: '/',
    name: 'home',
    redirect: '/index',
    component: () => import('/@/views/Home.vue'),
    children: [
      {
        path: '/index',
        name: 'index',
        component: () => import('/@/views/Index.vue'),
      },
      {
        path: '/about',
        name: 'about',
        component: () => import('/@/views/About.vue'),
      }
    ]
  },
];
//导入生成的路由数据
const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

router.beforeEach(async (_to, _from, next) => {
  NProgress.start();
  next();
});

router.afterEach((_to) => {
  NProgress.done();
});

export default router;
